var t = getApp();

Page({
  data: {
    hiddenmodalput: !0,
    nameInput: "",
    _num: 0,
    Wshow: !1,
    cdDisReason: "",
    nmDisReason: "",
    arr: []
  },
  onLoad: function(options) {
    var that = this
    var fenzuid = options.fenzuid
    var zid = options.zid
    that.setData({
      fenzuid: fenzuid,
      zid: zid
    })
  },
  onReady: function() {
    this.getAllfenzuuser()
  },
  menuClick: function(t) {
    console.log(t.target.dataset), this.setData({
      _num: t.target.dataset.num,
      nmDisReason: t.target.dataset.text,
      cdDisReason: t.target.dataset.uuid
    });
  },
  Wconfirm: function(a) {
    var e = this,
      o = wx.getStorageSync("log") || "",
      n = wx.getStorageSync("patientid") || "";
    wx.request({
      url: t.globalData.dic + "doctor/sign/break/" + o + "/" + n,
      data: {
        cdDisReason: e.data.cdDisReason,
        nmDisReason: e.data.nmDisReason
      },
      method: "POST",
      header: {
        "Content-Type": "application/x-www-form-urlencoded"
      },
      success: function(t) {
        console.log(t.data), 200 == t.data.code && (e.setData({
          Wshow: !1
        }), e.onClock());
      }
    });
  },
  Wcall: function(t) {
    this.setData({
      Wshow: !1
    });
  },
  shu: function(a) {
    wx.navigateTo({
      url: "/hyb_yl/backstageFollowUp/pages/healthRecord/healthRecord"
    });
  },
  nameInput: function(t) {
    this.setData({
      nameInput: t.detail.value
    });
  },
  cancel: function() {
    this.setData({
      hiddenmodalput: !0
    });
  },
  confirm: function() {
    var a = this,
      e = wx.getStorageSync("log") || "",
      o = wx.getStorageSync("creater") || "",
      n = wx.getStorageSync("groupid") || "";
    a.setData({
      hiddenmodalput: !0
    }), console.log(a.data.nameInput), wx.request({
      url: t.globalData.dic + "doctor/manage/group/update/" + e,
      data: {
        groupName: a.data.nameInput,
        creater: o,
        groupId: n
      },
      method: "POST",
      header: {
        "Content-Type": "application/x-www-form-urlencoded"
      },
      success: function(t) {
        console.log(t.data), a.setData({
          name: a.data.nameInput
        });
      }
    });
  },
  sectionalizationImg: function(a) {
    var e = this;
    wx.getStorageSync("log");
    wx.showActionSheet({
      itemList: ["重命名分组", "解散分组"],
      success: function(a) {
        console.log(a.tapIndex), 0 == a.tapIndex ? e.setData({
          hiddenmodalput: !e.data.hiddenmodalput
        }) : wx.showModal({
          title: "解散分组",
          content: "确认解散分组吗？",
          success: function(a) {
            if (a.confirm) {
              var e = wx.getStorageSync("log") || "",
                o = wx.getStorageSync("groupid") || "";
              wx.request({
                url: t.globalData.dic + "doctor/manage/group/delete/" + e + "/" + o,
                success: function(t) {
                  console.log(t.data), wx.navigateBack({
                    delta: 1
                  });
                }
              });
            } else a.cancel;
          }
        });
      }
    });
  },
  sectionalizationImg1: function(a) {
    var e = this;
    var zid = e.data.zid
    var q_id = a.currentTarget.dataset.q_id
    var beizhu = a.currentTarget.dataset.name
    var u_id = a.currentTarget.dataset.u_id
    wx.showActionSheet({
      itemList: ["移出分组", "移动到其他分组", "解除签约", "修改备注"],
      success: function(s) {
        0 == s.tapIndex ?
          t.util.request({
            'url': 'entry/wxapp/Docuser.Addfenzu',
            data: {
              q_id: q_id,
              op: 'yidongfenz'
            },
            success: function(res) {
              console.log(res)
              var pages = getCurrentPages();
              var prevPage = pages[pages.length - 2];
              prevPage.setData({
                type: 1
              })
              wx.showToast({
                title: "移出分组成功",
                icon: "none",
                duration: 1e3,
                success: function() {
                  setTimeout(function() {
                    wx.navigateBack({
                      delta: 1
                    })
                  }, 2000)
                }
              });
            }
          }) : 1 == s.tapIndex ? (wx.navigateTo({
            url: "/hyb_yl/backstageFollowUp/pages/casControlmovement/casControlmovement?u_id=" + u_id + '&zid=' + zid + '&id=' + id + '&types=2',

          })) : 2 == s.tapIndex ? e.setData({
            Wshow: !0
          }) : 3 == s.tapIndex && (wx.setStorageSync("wznameModifier", a.currentTarget.dataset.name),
            wx.navigateTo({
              url: "/hyb_yl/backstageServicess/pages/casControlname/casControlname?beizhu=" + beizhu + '&id=' + id
            }));
      }
    });
  },
  onShow: function(a) {
    var that = this
    let pages = getCurrentPages();
    let currPage = pages[pages.length - 1];
    if (currPage.data.type == 1) {
      that.getAllfenzuuser();
    }
  },
  onClock: function(a) {
    var e = this,
      o = wx.getStorageSync("name") || "";
    e.setData({
      name: o
    });
    var n = wx.getStorageSync("log") || "",
      c = wx.getStorageSync("groupid") || "";
    wx.request({
      url: t.globalData.dic + "doctor/manage/listPatientByGroup/" + n + "/" + c,
      success: function(t) {
        console.log(t.data), e.setData({
          arr: t.data.data
        }), 0 == t.data.data.length && wx.showToast({
          title: "暂无患者",
          icon: "none",
          duration: 3e3
        });
      }
    });
  },
  getAllfenzuuser: function() {
    var that = this
    var fenzuid = that.data.fenzuid
    var zid = that.data.zid
    t.util.request({
      'url': 'entry/wxapp/Docuser.fenzuuser',
      data: {
        fenzuid: fenzuid,
        zid: zid,
        openid: wx.getStorageSync('openid'),
        op: 'display'
      },
      success: function(res) {
        console.log(res)
        that.setData({
          arr: res.data
        })
      }
    })
  }
});